# To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting
# ms-python.python added
import os
try:
	os.chdir(os.path.join(os.getcwd(), 'jupyter\\fluent'))
	print(os.getcwd())
except:
	pass
# %% [markdown]
# # listcomps
# ## 1 test for expression deduction

# %%
symbols = 'abcdefghijklmnopq'


# %%
ssym = [ord(ch) for ch in symbols if ch >= 'j']


# %%
ssym

# %% [markdown]
# ## 2. genrator expresions

# %%
colors = ['black', 'white']
sizes = ['S', 'M', 'L']
tshirts = [(size, color) for size in sizes for color in colors ]


# %%
print(tshirts)


# %%
for tshirts2 in ('%s %s' % (s, c) for s in sizes for c in colors):
    print(tshirts2)


# %%
symbols2 ='abcdefghijklmn'
tuple(ord(s) for s in symbols2)


# %%
import array
array.array('I', (ord(s) for s in symbols2))

# %% [markdown]
# ## 3. Tuples are not just Immutable lists
# + immutable lists
# + records with no field names

# %%
lax_coordinates = (33.9425, -118.408056)
city, year, pop, chg, area = ('Tokyo', '2003', 32450, 0.66, 8014)
traveler_ids = [('USA', '31195855'), ('BRA', 'CE342567'), ('ESP', 'XDA205856')]


# %%
for passport in traveler_ids: 
    print('%s/%s' %passport)


# %%
for country , _ in traveler_ids:
    print(country)


# %%
latitude, longitude = lax_coordinates


# %%
t = (20, 8)
quo , rem=divmod(*t)


# %%
a, b, *reset = range(5)


# %%
type(range(5))


# %%
from collections import namedtuple
City = namedtuple('City', 'name country population coordinates')
tokyo = City('Tokyo', 'JP', 36.933, (35.689722, 139.691667))


# %%
tokyo


# %%
tokyo.coordinates


# %%


